package ch.lom.clemens.android.bibliography;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;


public class MainPreferences extends PreferenceActivity {

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.mainpreferences);
		setContentView(R.layout.mainpreferences_addition);
	
		
		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
		String strPDFPath = pref.getString(getString(R.string.preference_pdfpath), DocumentActivity.DOCSDIR);
		
		EditTextPreference etp = (EditTextPreference)findPreference(getString(R.string.preference_pdfpath));
		etp.setSummary(strPDFPath);
		
		Button btn = (Button)findViewById(R.id.preferences_clearcache);
		btn.setOnClickListener(new OnClickListener() {
			public void onClick(View btn) {
				onClearCache(btn);
			}});

	}

	protected void onClearCache(View btn) {
		StartActivity.m_mendeley.clearCache();
	}
	
	
}
